home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8065 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: rahul.net!a2i!news
  2. From: terris@rahul.net (Terris Linenbach)
  3. Newsgroups: comp.lang.c++
  4. Subject: Serious trouble with STL and NT/Win95
  5. Date: 14 Feb 1996 05:29:18 GMT
  6. Organization: a2i network
  7. Message-ID: <4frrve$pnr@hustle.rahul.net>
  8. NNTP-Posting-Host: 534.rahul.net
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.6
  12.  
  13. The following applies to HP's STL implementation, including the version
  14. shipped in Microsoft Visual C++ 4.0.  Credit goes to David
  15. Williams.
  16.  
  17. 1. It is not thread-safe.  Do not attempt to perform
  18.    something on the same "type" of container in two different threads
  19.    at the same time.  (You are in trouble even if you try to do this with
  20.    _different_ objects -- notice I said "type" and not "object")
  21.  
  22.    By "type", I mean a particular instantiation, such as
  23.       vector< int >
  24.  
  25.    This is because most STL classes have statics in them that are not
  26.    accessed in a thread-safe manner.
  27.  
  28. 2. Do not pass *most* STL containers across DLL/EXE boundaries.  Vectors
  29.    are OK.
  30.  
  31.    This is because most STL classes have statics.  In 32-bit
  32.    Windows, DLLs and EXEs get their own copies of the statics.  This
  33.    causes problems.
  34.  
  35.    Vectors are not affected because vectors only have a static allocator,
  36.    which doesn't have any data or any virtual member functions.
  37.  
  38.    If you try something like passing a set to a function in a 
  39.    DLL, your program will crash.
  40.  
  41.